<h1>Listing posts</h1>
<div id="posts">
<% for post in @posts %>
<div class="post" id="post<%= post.id %>">
<h3><%= link_to (h post.title), post_path(post) %></h3> ( <%= post.comments.count %> comments )
<img src=<%= "/images/#{post.image.id};showfile"%> alt=<%= h "#{post.image.title}" %> />
<p><%= markdown post.body %></p>
<%= post.created_at %> 
<% if logged_in? and (post.user_id == current_user.id or current_user.admin == true ) %>
   <%= link_to 'Edit', edit_post_path(post) %>
   <%= link_to 'Destroy', post_path(post), :confirm => 'Are you sure?', :method => :delete %>
<% end %>
</div>
<% end %>
</div>
<br />

<%= link_to 'New post', new_post_path, :class => 'lbOn' %>
